package leetcode;

import java.util.ArrayList;
import java.util.HashSet;

/**
 * @创建人 MBY381
 * @创建时间 2022/3/23 17:49
 * @描述 暂无
 */

public class Solution0345 {
    //    public static final int ABC=1;
    public static String reverseVowels(String s) {
        HashSet<Character> base = new HashSet<>();
        char[] sc = s.toCharArray();
        char[] yuan = new char[]{'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'};
        for (char c : yuan) {
            base.add(c);
        }
        ArrayList<Integer> tag = new ArrayList<>();
        ArrayList<Character> temp = new ArrayList<>();
        for (int i = 0; i < s.length(); i++) {
            if (base.contains(s.charAt(i))) {
                tag.add(i);
                temp.add(s.charAt(i));
            }
        }
        for (int i = 0; i < tag.size(); i++) {
            sc[tag.get(i)] = temp.get(temp.size() - 1 - i);
        }
//        StringBuilder sb=new StringBuilder();
//        for (char c:sc
//             ) {
//            sb.append(c);
//        }
        return new String(sc);
//        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(reverseVowels("leetcode"));
    }
}
